﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAL;
using Model;

namespace BLL
{

    /// <summary>
    /// DepartmentBLL
    /// </summary>
    public partial class DepartmentBLL
    {
        private readonly DepartmentDAL dal = new DepartmentDAL();
        public DepartmentBLL()
        {
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int? Insert(DepartmentModel model)
        {
            return dal.Insert(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(DepartmentModel model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public int Delete(string Id)
        {
            return dal.Delete(Id);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DepartmentModel Get(string Id)
        {
            DepartmentModel model = dal.Get(Id);
            return model;
        }

        /// <summary>
        /// 得到一个对象实体根据DepartmentNo
        /// </summary>
        /// <param name="DepartmentNo"></param>
        /// <returns></returns>
        public DepartmentModel GetModelByDepartmentNo(string DepartmentNo)
        {
            return dal.GetModelByDepartmentNo(DepartmentNo);
        }

        /// <summary>
        /// 根据Id和编码查询
        /// </summary>
        /// <param name="EmployeeNo"></param>
        /// <returns></returns>
        public int IsExistByIdAndDepartmentNo(string Id, string DepartmentNo)
        {
            return dal.IsExistByIdAndEmployeeNo(Id, DepartmentNo);
        }

        /// <summary>
        /// 根据编码查询
        /// </summary>
        /// <param name="EmployeeNo"></param>
        /// <returns></returns>
        public int IsExistByDepartmentNo(string EmployeeNo)
        {
            return dal.IsExistByDepartmentNo(EmployeeNo);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public IEnumerable<DepartmentModel> GetModelListByNoAndName(string departmentNo, string departmentName)
        {
            IEnumerable<DepartmentModel> ds = dal.GetModelListByNoAndName(departmentNo, departmentName);
            return ds;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<DepartmentModel> DataTableToList(DataTable dt)
        {
            List<DepartmentModel> modelList = new List<DepartmentModel>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                DepartmentModel model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public IEnumerable<DepartmentModel> GetList()
        {
            return dal.GetList();
        }

        
    }
}



